import os
from langchain_community.llms import QianfanLLMEndpoint
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser

os.environ["QIANFAN_AK"] = "7ZITkqmufR2g6MSLQUqsYAXB"
os.environ["QIANFAN_SK"] = "n2YLOoakGri5LfsK8Fxsax86tdeLEfpm"

llm = QianfanLLMEndpoint(temperature=0.9)
output_parser = StrOutputParser()
prompt = ChatPromptTemplate.from_messages(
    [
        ("user","我想去{location}旅游，能帮我简单介绍一下吗？")
    ]
)
chat = prompt | llm | output_parser
result = chat.invoke({"location": "海南"})
print(result)
